<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>
<html>
<head>
<script type="text/javascript" src="<s:url value="/common/scripts/jquery.treeview.min.js" />"></script>
<link rel="stylesheet" type="text/css" href="<s:url value="/common/css/jquery.treeview.css" />" />
<title>用户树</title>
<script type="text/javascript">
$(document).ready(function(){
	$("#browser").treeview({
		collapsed: true,
		animated: "fast"
	});
	$('input[name=users]').click(function(){
		select();
	});
	<s:if test="multiple">
		$('input[name="users"]').setCheckWithStr('<s:property value="list" />');
		select();
	</s:if><s:else>
		$('input[name="users"]').radio('<s:property value="list" />');
		select();
	</s:else>
	$('input[name="selectDept"]').click(function(){
		if($(this).isChecked()){
			$('#'+$(this).val()+' li input').checkAll();
		}else{
			$('#'+$(this).val()+' li input').inverse();
		}
		select();
	});
	$('#close').click(function(){
		var list = '';
		$('input[name="users"]:checked').each(function(){
			list +='<span class="br">'+$('#u'+$(this).val()).text()+'</span>';
		});
		<s:if test="multiple">
			opener.$('#showbox').html(list);
			opener.$('#hideUser').val($('input[name="users"]:checked').checkbox());
		</s:if><s:else>
			var uid = $('input[name="users"]').radio();
			opener.$('#hideUser').val(uid);
			opener.$('#name').text($('#u'+uid).text());
			opener.$('#dept').text($('#u'+uid).attr('class'))
		</s:else>
		window.close();
	});
});
function select(){
	var list = '';
	$('input[name="users"]:checked').each(function(){
		list +='<span>'+$('#u'+$(this).val()).text()+'</span><br/>';
	});
	$('#selected').html(list);
}

</script>
<style type="text/css">
#inerCont *{
	vertical-align: middle;
}
span.root{
	line-height: 14px;
}
</style>
</head>
<body>
<div style="width: 340px;">
	<div id="inerCont" style="width:200px;float: left;">
		<ul id="browser" class="filetree treeview-famfamfam" style="width: 100%">
			<li><span class="root">所有人员</span>
				<ul>
					<s:property value="htmlTree" escape="false" />
				</ul>
			</li>
		</ul>
	</div>
	<div style="width: 135px;float: right;" id="selected"></div>
	<div style="clear:both;width: 100%;"><input value="完成选择" type="button" id="close" /></div>
</div>
</body>
</html>